package org.opportunity.wishlist.travelwish.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.opportunity.wishlist.travelwish.pojo.dao.MenuDao;
import org.opportunity.wishlist.travelwish.pojo.model.Menu;

public class MenuWidget {

    private String choice;

    private Map<String, Menu> mapMenu;

    public MenuWidget() {

	mapMenu = new HashMap<String, Menu>();

	List<Menu> menus = getMenus();
	for (Menu menu : menus) {
	    mapMenu.put(menu.getPropertyName(), menu);
	}

    }

    private List<Menu> getMenus() {
	List<Menu> menus = null;
	try {
	    MenuDao dao = new MenuDao();
	    menus = dao.findAll();

	} catch (Exception e) {
	    e.printStackTrace();

	}
	return menus;
    }

    public void setChoice(String choice) {
	this.choice = choice;

    }

    public Menu getMenu() {
	return mapMenu.get(choice);
    }

}
